
<%--
 *  File:   ActivityManageSummary.jsp
 *  Desc:	the Lend slip summary page
 *
 *  Date		         Author		      Changes
 *  2009-10-22	  Only Jin		  Created
 *
 *  Copyright (C) 2000 - 2005 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  String privilegeCode = "SFE0150";
  String strTableName = "v_activitymanage";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>

<html>
<head>
<title>ActivityManageSummary</title>
<PageFlow:CheckPageFlow pageName="p_activitymanagesummary" />
<%
	String isNew = "";
	String isDefault = "";
	String paraIsDefault = "";
	//System.out.println("Trace \"isdefault\" ------- summary" + ((String)pageContext.getAttribute("isdefault")));
	if("Y".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=Y";
		paraIsDefault="Y";
	}else if("N".equals(((String)pageContext.getAttribute("isdefault")))||"Y".equals(request.getParameter("isdefault"))) {
		isDefault = "&isdefault=N";
		paraIsDefault="N";
	}
	
	
	HashMap userinfo = (HashMap)session.getAttribute("userinfo");
	String strFromuserid = (userinfo.get("userid")).toString();
	
	
	  
	  HashMap optionhash = (HashMap)pageContext.getAttribute("optionhash");
	  if(optionhash == null)
	  {
		  optionhash = new HashMap();
	  }
	  
	  String optionvalue =(String)optionhash.get("optionvalue");
	  
	  
	 // out.print(optionvalue);

	  
%>
<%@ include file="/inc/CatchError.inc"%>
<%@ include file="/inc/SumDiv.inc"%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript"
	src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript">
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "ActivityManageSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}
function page_new()
{
	//var id = cform.chooseactionid.value;
	//var startdate = cform.startdate.value;
	//var enddate = cform.enddate.value;
	//var readystartdate = cform.readystartdate.value;
	//var influencedate = cform.influencedate.value;
	var optionvalue=cform.optionvalue.value;
	
	<%isNew = "&isNew=Y";%>
	editurl="ActivityManageFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%><%=JspHelper.filterNull(isNew)%>&optionvalue="+optionvalue;
	//alert(editurl);
	self.location.href = editurl;
}

function page_edit(){

	var id = cform.activitymanageid.value;
	var startdate = cform.startdate.value;
	var enddate = cform.enddate.value;
	var readystartdate = cform.readystartdate.value;
	var influencedate = cform.influencedate.value;
	var status=cform.status.value;
	var configid=cform.activityconfigid.value;
	var strFromuserid=cform.strFromuserid.value;
	var userid=cform.userid.value;
	var optionvalue=cform.optionvalue.value;
	if(status==10 && strFromuserid!=userid){
		alert("<%= message.getMessageDesc("CAN_NOT_BE_EDIT") %>");
		return;
	}

	<%isNew = "&isNew=N";%>

	editurl = "ActivityManageFrm.jsp?<%= OvalTools.randomURL() %><%=JspHelper.filterNull(isDefault)%>&activitymanageid=" + id + "&activityconfigid=" + configid + "&languagecode=" + "<%= strLanguageCode %><%=JspHelper.filterNull(isNew)%>&startdate="+startdate+"&enddate="+enddate+"&readystartdate="+readystartdate+"&influencedate="+influencedate+"&status="+status+"&optionvalue="+optionvalue;
    self.location.href = editurl;
}

function page_info(seq)
{
    var id = document.cform['activitymanageid'+seq].value;
	var startdate = document.cform['startdate'+seq].value;
	var enddate = document.cform['enddate'+seq].value;
	var readystartdate = document.cform['readystartdate'+seq].value;
	var influencedate = document.cform['influencedate'+seq].value;
	var status=document.cform['status'+seq].value;
	var configid=document.cform['activityconfigid'+seq].value;
	
	document.cform.userid.value = document.cform['userid'+seq].value;
	document.cform.activitymanageid.value = id;
    document.cform.status.value = status;
    document.cform.activityconfigid.value = configid;
    document.cform.parentuserid.value = document.cform['parentuserid'+seq].value;
    document.cform.readystartdate.value = document.cform['readystartdate'+seq].value;
    document.cform.influencedate.value = document.cform['influencedate'+seq].value;
    document.cform.startdate.value = document.cform['startdate'+seq].value;
    document.cform.enddate.value = document.cform['enddate'+seq].value;
    self.location.href="ActivityManageFrmInfo.jsp?<%= OvalTools.randomURL() %>&activitymanageid="+id+"&activityconfigid="+configid+"&startdate="+startdate+"&enddate="+enddate+"&readystartdate="+readystartdate+"&influencedate="+influencedate+"&status="+status;
}
function page_delete()
{
	var cform = document.cform;
	var id = cform.activitymanageid.value;
	var status=cform.status.value;
	var strFromuserid=cform.strFromuserid.value;
	var userid=cform.userid.value;

	if(status==10 && strFromuserid!=userid){
		alert("<%= message.getMessageDesc("CAN_NOT_BE_DEL") %>");
		return;
	}

	if(isEmpty(id) || id == -1) return;
	if ( ! confirm("<%= message.getMessageDesc("ARE_YOU_SURE") %>") )  return;
	cform.actionname.value="delete";
	isRunning = true;
    cform.submit();
}
function clickRow11(obj,idx)
{
  var cform = document.cform;
  cform.radiorow[idx].checked=true;
  cform.activitymanageid.value = eval('obj.all.activitymanageid'+idx).value;
  cform.status.value = eval('obj.all.status'+idx).value;
}

function clickRow(id,status,configid,userid)
{
  document.cform.activitymanageid.value = id;
  document.cform.status.value = status;
  document.cform.activityconfigid.value = configid;
  document.cform.userid.value = userid;
}


</script>
</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher"><input
	type="hidden" name="pagename" value="p_activitymanagesummary"> 
	<input type="hidden" name="actionname"> <%--  page location   --%> 
	<input type="hidden" name="isdefault" value="<%= paraIsDefault %>">
	<input type="hidden" name="strFromuserid" value="<%= strFromuserid %>">
	<input type="hidden" name="optionvalue" value="<%= optionvalue %>">
	<%@ include file="/inc/PageLocation.inc"%>

<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td>
      <table width="100%" border="0" cellspacing="0">
        <tr>
          <td class="summary_top" colspan="2" ></td>
        </tr>
	<%@ include file="/inc/SummarySearch.inc" %>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table border="1" cellspacing="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellpadding="0" width="100%">

        <tr class="deepblue-left">
          <td width="5%" class="title_center">&nbsp;</td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','activitymanagecode')"><%= label.getLabelName("L_Activity")+label.getLabelName("L_Code") %></a></td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','activitymanagename')"><%= label.getLabelName("L_Activity")+label.getLabelName("L_ItemName1") %></a></td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','activityconfigname')"><%= label.getLabelName("L_Activity")+label.getLabelName("L_Kind") %></a></td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','employeename')"><%= label.getLabelName("L_Maker")%></a></td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','createdate')"><%= label.getLabelName("L_createdate")%></a></td>
          <td width="30%" class="title_center"><a href="javascript:page_summary('orderby','comments')"><%= label.getLabelName("L_Comment")%></a></td>
          <td width="10%" class="title_center"><a href="javascript:page_summary('orderby','statusname')"><%= label.getLabelName("L_status") %></a></td>
        </tr>
       
            <%
             Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
             if(totalsummary == null)
             {
            	 totalsummary = new Vector();
             }
             String strClassType = new String("");   
             int i=0;
             String strChecked = "";
             boolean bHasChecked = false;
             Integer nDefaultId = null; 
             Date nDefaultState = null; 
             Date nDefaultEnddate = null; 
             Date nDefaultReadystartdate = null; 
             Date nDefaultInfluencedate = null;
             Integer nDefaultStatus = null;
             Integer nDefaultConfigId = null;
             Integer nDefaultUserId = null;
             
             Integer nDefaultParentUserId = null;
          %>   
          <logic:iterate id="actionhash" collection="<%= totalsummary %>" indexId="seq">
          <%
            if(i%2 == 1)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            if(!bHasChecked)
            {
            	nDefaultId = (Integer)((HashMap)pageContext.getAttribute("actionhash")).get("activitymanageid");
            	nDefaultState = (Date)((HashMap)pageContext.getAttribute("actionhash")).get("startdate");
            	nDefaultEnddate = (Date)((HashMap)pageContext.getAttribute("actionhash")).get("enddate");
            	nDefaultReadystartdate = (Date)((HashMap)pageContext.getAttribute("actionhash")).get("readystartdate");
            	nDefaultInfluencedate = (Date)((HashMap)pageContext.getAttribute("actionhash")).get("influencedate");
            	nDefaultStatus = (Integer)((HashMap)pageContext.getAttribute("actionhash")).get("status");
            	nDefaultConfigId = (Integer)((HashMap)pageContext.getAttribute("actionhash")).get("activityconfigid");
            	nDefaultUserId=(Integer)((HashMap)pageContext.getAttribute("actionhash")).get("userid");
            	
            	nDefaultParentUserId=(Integer)((HashMap)pageContext.getAttribute("actionhash")).get("parentuserid");
              
              bHasChecked = true;
              strChecked = "Checked";
            }
            else
            {
              strChecked = "";
            }
            
            i++;
            
          %>            
    <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  onClick="radiotrue('activitymanageid<%=JspHelper.filterNull( i )%>');javascript:clickRow('<oval:write name="actionhash" property="activitymanageid" />','<oval:write name="actionhash" property="status" />','<oval:write name="actionhash" property="activityconfigid" />','<oval:write name="actionhash" property="userid" />');" class="<%=JspHelper.filterNull( strClassType )%>"> 
     <td><input <%=JspHelper.filterNull( strChecked )%> id="activitymanageid<%=JspHelper.filterNull( i )%>" type="radio" name="order" value="<oval:write name="actionhash" property="activitymanageid"/>" class="normalradio"/></td>            
	 <td><a onclick="page_info(<%=new Integer(i)%>)"><custom:write property="activitymanagecode" name="actionhash" nbsp="true" /></a></td>
	 <td><custom:write property="activitymanagename" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="activityconfigname" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="employeename" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="createdate" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="comments" name="actionhash" nbsp="true" /></td>
	 <td><custom:write property="statusname" name="actionhash" nbsp="true" /></td>
      <custom:hidden  property="startdate" name="actionhash" colIndex="<%=new Integer(i)%>"/> 
      <custom:hidden  property="enddate" name="actionhash" colIndex="<%=new Integer(i)%>"/> 
      <custom:hidden  property="readystartdate" name="actionhash" colIndex="<%=new Integer(i)%>"/> 
      <custom:hidden  property="influencedate" name="actionhash" colIndex="<%=new Integer(i)%>"/>
      <custom:hidden  property="status" name="actionhash" colIndex="<%=new Integer(i)%>"/>
      <custom:hidden  property="activityconfigid" name="actionhash" colIndex="<%=new Integer(i)%>"/>
      <custom:hidden  property="userid" name="actionhash" colIndex="<%=new Integer(i)%>"/> 
      <custom:hidden  property="parentuserid" name="actionhash" colIndex="<%=new Integer(i)%>"/> 
      <custom:hidden  property="parentuserid" name="actionhash" colIndex="<%=new Integer(i)%>"/>     
      
    </tr>
   </logic:iterate> 
       
		     <input type="hidden" name="activitymanageid" value="<%=JspHelper.filterNull( nDefaultId )%>"> 
			 <input type="hidden" name="startdate" value="<%=JspHelper.filterNull( nDefaultState )%>"> 
			 <input type="hidden" name="enddate" value="<%=JspHelper.filterNull(nDefaultEnddate  )%>"> 
			 <input type="hidden" name="readystartdate" value="<%=JspHelper.filterNull(nDefaultReadystartdate  )%>"> 
			 <input type="hidden" name="influencedate" value="<%=JspHelper.filterNull( nDefaultInfluencedate )%>">
			 <input type="hidden" name="status" value="<%=JspHelper.filterNull( nDefaultStatus )%>">
			 <input type="hidden" name="activityconfigid" value="<%=JspHelper.filterNull( nDefaultConfigId )%>">
			 <input type="hidden" name="userid" value="<%=JspHelper.filterNull( nDefaultUserId )%>"> 
			 <input type="hidden" name="parentuserid" value="<%=JspHelper.filterNull( nDefaultParentUserId )%>"> 
			         
			          <%@ include file="/inc/SummaryAction.inc" %>
			          
		    </table>
		      <table width="100%" border="0" cellspacing="0" cellpadding="0">
		        <tr>
		          <td class="summary_top" ></td>
		        </tr>
		        <tr>
		          <td class="td_center">
		          <input type="hidden" name="delactivitymanageid">
		          <a onclick="page_new();"><custom:button type="1" label="L_New" imgsrc="new.gif" border="0" style="width:60"/></a>
		          <%
		             Vector usersummary = (Vector)pageContext.getAttribute("usersummary");
		             if(usersummary == null)
		             {
		            	 usersummary = new Vector();
		             }
		          	 
		          %>
		          <%if(usersummary.size()>0 || ((Integer)userinfo.get("userid")).intValue()==3){ %>

		          <%} %>
		          <a onclick="page_edit()"><custom:button type="1" label="L_Edit" imgsrc="edit.gif" border="0" style="width:60"/></a>
		          <a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>
		          </td>
		        </tr>
		      </table>
		    </td>
		  </tr>

</table>
 </form>
</body>
</html>